package com.sychip.fhc.base

import com.sychip.fhc.app.data.source.dto.BleDeviceDto

interface ViewModelStates {
    object Null : ViewModelStates
    object Loading : ViewModelStates
    data class Success(val data: List<BleDeviceDto>) : ViewModelStates
    data class Error(val throwable: Throwable? = null) : ViewModelStates

}



enum class UiStatus { Loading, Error, Success, Null }
data class CommonUiState<T>(
    val isInInit: Boolean = true,  //用来区分画面是否初始化
    val toastMsgId: Int? = null,
    val dataList: List<T> = emptyList(),
    val status: UiStatus = UiStatus.Null
){
}


data class UiDataState(
    val title: String = "",
    val toastMsgId:Int? = null,
    val toastMsgArgs: Array<Any>? = emptyArray<Any>(),
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as UiDataState

        if (toastMsgId != other.toastMsgId) return false
        if (title != other.title) return false
        if (!toastMsgArgs.contentEquals(other.toastMsgArgs)) return false

        return true
    }

    override fun hashCode(): Int {
        var result = toastMsgId ?: 0
        result = 31 * result + title.hashCode()
        result = 31 * result + (toastMsgArgs?.contentHashCode() ?: 0)
        return result
    }
}